package com.yanqu.road.server.cmd.activity.feast;

import com.yanqu.road.entity.activity.feast.config.ShanHeFeastConfig;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.ShanHeFeastProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.server.manager.activity.feast.CrossFeastMgr;
import com.yanqu.road.server.manager.activity.feast.activity.CrossFeastActivity;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.GameErrorCode;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.YanQuMessageUtils;


@Cmd(code = CrossProtocol.C_CROSS_SHAN_HE_FEAST_GET_OTHER_INFO_RESP, desc = "跨服查看玩家信息回复")
public class CrossFeastGetOtherInfoRespCmd extends CrossCommand {

    private long getUserId;
    private long getServerId;
    private long userId;
    private long powerVal;
    private Integer activityId;
    private ShanHeFeastProto.FeastGetOtherInfoFromCrossRespMsg reqMsg;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        reqMsg = ShanHeFeastProto.FeastGetOtherInfoFromCrossRespMsg.parseFrom(packet.getBytes());
        getUserId = reqMsg.getUserId();
        getServerId = reqMsg.getServerId();
        userId = packet.getPlayerId();
        activityId = reqMsg.getActivityId();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossFeastActivity activity = CrossFeastMgr.getActivity(activityId);
        if (activity == null) {
            ret = GameErrorCode.E_SHAN_HE_FEAST_ACTIVITY_NOT_FOUND;
            return;
        }
        ShanHeFeastConfig config = activity.getConfig();
        if (config == null) {
            ret = GameErrorCode.E_SHAN_HE_FEAST_CONFIG_NOT_FOUND;
            return;
        }
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(Protocol.U_SHAN_HE_FEAST_PVE_GET_OTHER_USER_INFO, reqMsg.getRespMsg());
        MessageHelper.sendPacket(getServerId, getUserId, pbMsg);

    }

    @Override
    public void sendData() {
    }
}
